<template>
	<div class="" style="overflow:auto;height:70vh">
		<div class="rulesBox">
			<p class="ruleText ruleText1">发送规则</p>
			<div class="topRules">
				<div class="operateDiv">
					<p class="operateText"><sup>*</sup>用户标签:</p>
					<el-radio v-model="userLabel" label="982001">全部用户</el-radio>
					<el-radio v-model="userLabel" label="982002" :disabled="isJoin">全部会员</el-radio>
					<el-radio v-model="userLabel" label="982003" :disabled="isJoin">会员自动充电</el-radio>
					<el-radio v-model="userLabel" label="982004" disabled>非会员</el-radio>
					<span class="checkTxt" v-show="diffUserLabel" v-text="diffText" style="right:-4%"></span>
				</div>
				<div class="operateDiv">
					<p class="operateText"><sup>*</sup>用户单次参加次数:</p>
					<el-radio v-model="userSingleCountType" label="0">不限制</el-radio>
					<el-radio v-model="userSingleCountType" label="1">限定次数</el-radio>
					每<el-input maxlength=2 :disabled="iSelectSingleCount" v-model="limitCount" class="scount"></el-input>日可参与
					<el-input maxlength=2 class="scount" :disabled="iSelectSingleCount" v-model="userSingleCount"></el-input>次
					<span class="checkTxt" v-show="diffJoin" v-text="diffText" style="right:-15%"></span>
				</div>
				<div class="operateDiv">
					<p class="operateText"><sup>*</sup>用户活动参加次数:</p>
					<el-radio v-model="userJoinType" label="0">不限制</el-radio>
					<el-radio v-model="userJoinType" label="1">限定次数</el-radio>
					活动周期可参与
					<el-input maxlength=3 class="scount" :disabled="isUserTotalCount" v-model="userTotalCount"></el-input>次
					<span class="checkTxt" v-show="diffTotalJoin" v-text="diffText" style="right:-15%"></span>
				</div>
				<div class="operateDiv">
					<p class="operateText"><sup>*</sup>用户单次获取金额:</p>
					<el-radio v-model="userSingleMoneyType" label="0">不限制</el-radio>
					<el-radio v-model="userSingleMoneyType" label="1">限定金额</el-radio>
					每<el-input maxlength=2 :disabled="iSelectSingleMoney" v-model="limitMoney" class="scount"></el-input>日
					最高领取<el-input maxlength=6 class="scount" :disabled="iSelectSingleMoney" v-model="userSingleMoney"></el-input>元
					<el-tooltip class="item" effect="dark" content="活动页面增加获取金额上限提示" placement="right">
						<i class="el-icon-warning-outline"></i>
					</el-tooltip>
					<span class="checkTxt" v-show="diffSingleMoney" v-text="diffText" style="right:-15%"></span>
				</div>
				<div class="operateDiv">
					<p class="operateText"><sup>*</sup>用户活动获取金额:</p>
					<el-radio v-model="userTotalMoneyType" label="0">不限制</el-radio>
					<el-radio v-model="userTotalMoneyType" label="1">限定金额</el-radio>
					活动周期
					最高领取<el-input maxlength=6 class="scount" :disabled="iSelectUserTotalMoney" v-model="userTotalMoney"></el-input>元
					<el-tooltip class="item" effect="dark" content="活动页面增加获取金额上限提示" placement="right">
						<i class="el-icon-warning-outline"></i>
					</el-tooltip>
					<span class="checkTxt" v-show="diffUserTotalMoney" v-text="diffText" style="right:-15%"></span>
				</div>
				<div class="operateDiv">
					<p class="operateText"><sup>*</sup>总领取人数:</p>
					<el-radio v-model="userReceiveTotalType" label="0">不限制</el-radio>
					<el-radio v-model="userReceiveTotalType" label="1">限定人数</el-radio>
					<el-input v-model="userReceiveTotal" maxlength=8 class="scount1" :disabled="iSelectNum"></el-input>人
					<span class="checkTxt" v-show="diffReceive" v-text="diffText" style="right:-15%"></span>
				</div>
				<div class="operateDiv">
					<p class="operateText"><sup>*</sup>总发放金额:</p>
					<el-radio v-model="moneyReceiveTotalType" label="0">不限制</el-radio>
					<el-radio v-model="moneyReceiveTotalType" label="1">限定金额</el-radio>
					<el-input class="scount1" maxlength=8 v-model="moneyReceiveTotal" clearable :disabled="iSelectMoney">
					</el-input>元
					<p class="alarm" @click="alarmAlert">余额预警</p>
					<span class="checkTxt" v-show="diffMoneyReceiveTotal" v-text="diffText" style="right:-15%"></span>
				</div>
			</div>
		</div>
		<div class="rulesBox">
			<p class="ruleText ruleText2">微信分享设置</p>
			<div class="operateDiv">
				<p class="operateText"><sup>*</sup>分享标题:</p>
				<el-input placeholder="请输入分享标题" v-model.trim="shareTitle" clearable maxlength=50>
				</el-input>
				<span class="checkTxt" v-show="showTheme">请输入3~50个字符</span>
				<span class="checkTxt" v-show="diffShareTitle" v-text="diffText" style="right:-13%"></span>
			</div>
			<div class="operateDiv">
				<p class="operateText"><sup>*</sup>分享描述:</p>
				<el-input placeholder="请输入分享描述" v-model.trim="shareContent" clearable maxlength=50>
				</el-input>
				<span class="checkTxt" v-show="showContent">请输入3~50个字符</span>
				<span class="checkTxt" v-show="diffShareContent" v-text="diffText" style="right:-13%"></span>
			</div>
			<div class="operateDiv">
				<p class="operateText"><sup>*</sup>分享图片:</p>
				<el-upload
					class="newRules"	
					:limit="1"
					:show-file-list='false'
					:action="picUpload"
					:data="picData"
					ref="shareImg"
					:on-success="homeImgSuccess"
					:before-upload="beforeAvatarUpload">
					<img v-if="shareImageUrl" :src="PIC_URL+shareImageUrl" class="avatar">
					<i v-else class="el-icon-plus avatar-uploader-icon"></i>
				</el-upload>
				<p class="textTip" style="width:95%">(支持1MB以下JPG,PNG格式的图片)</p>
				<span class="checkTxt" v-show="diffShareImgMd5" v-text="diffText" style="right:-15%"></span>
			</div>
		</div>
		<div class="btns">
			<div class="pageBtn btn next" @click="goPrize(-1)">上一步</div>
			<div class="pageBtn btn save" @click="goPrize(0)">保存</div>
			<div class="pageBtn btn next" @click="goPrize(1)">下一步</div>
		</div>
		<div v-if="showAlarmDiv">
			<Alarm @closeAlarm="closeAlarm" :num="moneyAlarmLimit" :email1="emailAlarm" :repeatRecordContent="repeatRecordContent"></Alarm>
		</div>
	</div>
</template>

<script>
	import Alarm from'./children/Alarm'
	import {SAVE_OR_EDIT_RULE_LOTTERY,FILE_UPLOAD,FIND_RULE_LOTTERY_BY_CODE} from '@/config/url'
	import Bus from '@/bus.js'
	import { publicVM } from "_config/public.js"

	export default {
		mixins:[publicVM],
		components: {
			Alarm
		},
		data() {
			return {
				input: '',
				input1: '',
				value: '',
				count: '',
				role: '',
				picUpload:FILE_UPLOAD,
				showAlarmDiv: false,
				activityCode:sessionStorage.getItem('activityCode'),
				userLabel:'982002',//用户标签：982001 全部用户，982002 全部会员，982003 会员自动充电，982004 非会员
				userJoinType:'0',//用户参与活动限制类型：0 关闭，1活动周期，2每天
				joinType:'1',//
				userSingleCountType:'0',//用户单次参与活动次数类型
				userSingleCount:'0',//用户单次参与活动次数：0 不限
				limitCount:'0',//每日次数限制
				userTotalCount:'0',//用户总参与活动次数：0 不限
				userSingleMoneyType:'0',//用户单次获取金额类型
				userSingleMoney:'0',//用户获取金额：0 不限
				limitMoney:'0',//每日金额限制
				userTotalMoney:'0',//用户总获取金额：0 不限
				userReceiveTotal:'0',//礼品总领取总人数：0 不限
				userReceiveTotalType:'0',//类型
				moneyReceiveTotalType:'0',
				moneyReceiveTotal:'0',//活动发放总金额：0 不限
				moneyAlarm:'0',//活动余额告警：0关闭，1开启
				moneyAlarmLimit:null,//告警金额设置
				emailAlarm:null,//告警邮箱
				shareTitle:null,//微信分享标题
				shareContent:null,//微信分享描述
				shareImg:null,//微信分享图片
				shareImgMd5:null,//微信分享图片md5值
				shareImageUrl:null,//图片地址
				receiveType:sessionStorage.getItem('receiveType'),//领取类型：993023 打折，993024 抽取, 993025 领取
				repeatRecord:sessionStorage.getItem('repeatRecord'),//活动复录：0 初录，1 复录
				showTheme:false,//显示标题提示
				showContent:false,//显示内容提示
				iSelectRate:true,//是否可以选择次数
				iSelectNum:true,//是否可以选择次数
				iSelectMoney:true,//金额
				repeatRecordContent:null,//初录信息
				diffText:'与初录不一致',
				diffUserLabel:false,
				diffJoin:false,
				diffReceive:false,
				diffMoneyReceiveTotal:false,
				diffShareTitle:false,
				diffShareContent:false,
				diffShareImgMd5:false,
				clickNext:false,
				isIdentical:null,//0 一致，1 不一致
				iSelectSingleCount:true,//是否用户单次参加次数
				isUserTotalCount:true,//
				diffSingleMoney:false,//
				diffUserTotalMoney:false,//
				diffTotalJoin:false,//
				iSelectSingleMoney:true,//
				userTotalMoneyType:'0',//
				iSelectUserTotalMoney:true,//
				diffLeftAlarm:false,//余额预警是否一致
				isJoin:false
			}
		},
		watch:{
			//用户单次参加次数
			userSingleCountType(val){
				if(val == 0){
					this.userSingleCount = 0
					this.limitCount = 0
					this.iSelectSingleCount = true
				}else{
					this.iSelectSingleCount = false
					if(this.repeatRecordContent){
						if(this.repeatRecordContent.userSingleCount < 1){
							this.userSingleCount = 1
						}else{
							this.userSingleCount = this.repeatRecordContent.userSingleCount
						}
						if(this.repeatRecordContent.limitCount < 1){
							this.limitCount = 1
						}else{
							this.limitCount = this.repeatRecordContent.limitCount
						}
					}else{
						this.userSingleCount = 1
						this.limitCount = 1
					}
				}
			},
			limitCount(val){
				val = Number(val)
				this.diffJoin = this.repeatRecord == 1 && this.repeatRecordContent && val != this.repeatRecordContent.limitCount
			},	
			userSingleCount(val){
				val = Number(val)
				this.diffJoin = this.repeatRecord == 1 && this.repeatRecordContent && val != this.repeatRecordContent.userSingleCount
			},


			//用户活动参加次数
			userJoinType(val){
				if(val == 0){
					this.userTotalCount = 0
					this.isUserTotalCount = true
				}else{
					this.userTotalCount = 1
					this.isUserTotalCount = false
					if(this.repeatRecordContent){
						if(this.repeatRecordContent.userTotalCount > 1){
							this.userTotalCount = this.repeatRecordContent.userTotalCount
						}else{
							this.userTotalCount = 1
						}
					}
				}
			},
			userTotalCount(val){
				if(this.userReceiveTotalType == 1){
					if(this.userJoinType == 1){
						val = Number(val)
					}
				}
				this.diffTotalJoin = this.repeatRecord == 1 && this.repeatRecordContent && val != this.repeatRecordContent.userTotalCount
			},

			//用户单次获取金额
			userSingleMoneyType(val){
				if(val == 0){
					this.iSelectSingleMoney = true
					this.limitMoney = 0
					this.userSingleMoney = 0
				}else{
					this.iSelectSingleMoney = false
					this.limitMoney = 1
					this.userSingleMoney = 0.01
					if(this.repeatRecordContent){
						if(this.repeatRecordContent.userSingleMoney < 0.01){
							this.userSingleMoney = 0.01
						}else{
							this.userSingleMoney = this.repeatRecordContent.userSingleMoney
						}
						if(this.repeatRecordContent.limitMoney < 1){
							this.limitMoney = 1
						}else{
							this.limitMoney = this.repeatRecordContent.limitMoney
						}
					}
					
				}
			},
			limitMoney(val){
				val = Number(val)
				this.diffSingleMoney = this.repeatRecord == 1 && this.repeatRecordContent && val != this.repeatRecordContent.limitMoney
			},	
			userSingleMoney(val){
				val = Number(val)
				this.diffSingleMoney = this.repeatRecord == 1 && this.repeatRecordContent && val != this.repeatRecordContent.userSingleMoney
			},

			//用户活动获取金额
			userTotalMoneyType(val){
				if(val == 0){
					this.iSelectUserTotalMoney = true
					this.userTotalMoney = 0
				}else{
					this.userTotalMoney = 0.01
					if(this.repeatRecordContent){
						if(this.repeatRecordContent.userTotalMoney > 0.01){
							this.userTotalMoney = Number(this.repeatRecordContent.userTotalMoney).toFixed(2)
						}else{
							this.userTotalMoney = 0.01
						}
					}
					this.iSelectUserTotalMoney = false
				}
			},
			userTotalMoney(val){
				val = Number(val)
				this.diffUserTotalMoney = this.repeatRecord == 1 && this.repeatRecordContent && val != this.repeatRecordContent.userTotalMoney
			},

			//总领取人数
			userReceiveTotal(val){
				if(val == 0){
					this.iSelectNum = true
					this.userTotal = 0
				}else{
					if(this.repeatRecordContent.userTotal > 1){
						this.userTotal = this.repeatRecordContent.userTotal
					}else{
						this.userTotal = 1
					}
					this.iSelectNum = false
				}

				if(this.repeatRecord == 1 && this.repeatRecordContent){
					if(val != this.repeatRecordContent.userReceiveTotal){
						this.diffReceive = true
					}else{
						this.diffReceive = this.userTotal != this.repeatRecordContent.userTotal
					}
				}
			},
			userReceiveTotalType(val){
				if(val == 0){
					this.iSelectNum = true
					this.userReceiveTotal = 0
				}else{
					this.iSelectNum = false
					// this.userReceiveTotal = 1
					if(this.repeatRecordContent){
						if(this.userReceiveTotal > 1){
							this.userReceiveTotal = this.userReceiveTotal
						}else{
							this.userReceiveTotal = 1
						}
					}
				}
			},
			userReceiveTotal(val){
				val = Number(val)
				this.diffReceive = this.repeatRecord == 1 && this.repeatRecordContent && val != this.repeatRecordContent.userReceiveTotal
			},

			//总发放金额
			moneyReceiveTotalType(val){
				if(val == 0){
					this.moneyAlarmLimit = ''
					this.emailAlarm = ''
					this.moneyReceiveTotal = 0
					this.iSelectMoney = true
				}else{
					this.iSelectMoney = false
					// this.moneyReceiveTotal = '1.00'
					if(this.repeatRecordContent){
						if(this.repeatRecordContent.moneyReceiveTotal >= 1){
							this.moneyReceiveTotal = this.moneyReceiveTotal > 1?Number(this.moneyReceiveTotal).toFixed(2):'100.00'
						}else{
							this.moneyReceiveTotal = '100.00'
						}
					}else{
						this.moneyReceiveTotal = '100.00'
					}
					
				}
			},
			moneyReceiveTotal(val){
				if(this.repeatRecord == 1){
					if(this.repeatRecordContent){
						if(val == this.repeatRecordContent.moneyReceiveTotal && this.diffLeftAlarm){
							this.diffMoneyReceiveTotal = false
						}else{
							// if(this.moneyAlarmLimit != this.repeatRecordContent.moneyAlarmLimit || this.emailAlarm != this.repeatRecordContent.emailAlarm){
								this.diffMoneyReceiveTotal = true
							// }else{
							// 	this.diffMoneyReceiveTotal = false
							// }
						}
					}
				}
			},
			money(val){
				this.diffMoneyReceiveTotal = this.repeatRecord == 1 && this.repeatRecordContent && !this.diffLeftAlarm && val != this.repeatRecordContent.moneyReceiveTotal
			},
			diffLeftAlarm(val){
				if(this.repeatRecord == 1){
					this.diffMoneyReceiveTotal = this.diffMoneyReceiveTotal && !val
				}
			},

			//用户标签
			userLabel(val){
				this.diffUserLabel = this.repeatRecord == 1 && this.repeatRecordContent && val != this.repeatRecordContent.userLabel
			},
			//分享
			shareTitle(val){
				let leng = val.length
				if(leng < 3){
					this.showTheme = true
				}else{
					this.showTheme = false
					this.diffShareTitle = this.repeatRecord == 1 && this.repeatRecordContent && val != this.repeatRecordContent.shareTitle
				}
			},
			shareContent(val){
				let leng = val.length
				if(leng < 3){
					this.showContent = true
				}else{
					this.showContent = false
					this.diffShareContent = this.repeatRecord == 1 && this.repeatRecordContent && val != this.repeatRecordContent.shareContent
				}
			},
			shareImgMd5(val){
				this.diffShareImgMd5 = this.repeatRecord == 1 && this.repeatRecordContent && val != this.repeatRecordContent.shareImgMd5
			},
		},
		mounted(){
			this.getFirstData();
			if(sessionStorage.getItem('activityScenes') == '994001'){
				this.isJoin = true;
				this.userLabel = '982001'
			}else{
				this.userLabel = '982002'
			}	
		},
		computed:{
			picData(){
				return {
					repeatRecord:this.repeatRecord,
					htmlType:0
				}
			},
			canAlram(){
				return this.moneyReceiveTotal != 0
			}
		},
		methods:{
			getFirstData(){
				this.$fetch(FIND_RULE_LOTTERY_BY_CODE,
						{
						"activityCode":this.activityCode,
						'repeatRecord':'0',
						},
					)
					.then(res=>{
						if(res.status == 1){
							this.repeatRecordContent = res.data
							if(res.data){
								this.repeatRecordContent = res.data
								if(this.repeatRecord == 0){
									this.updateData(res.data)
								}else{
									if(sessionStorage.getItem('activityScenes') != '994001'){
										if(res.data.userLabel != '982002'){
											this.diffUserLabel = true
										}
									}
									this.getSecData()
								}
							}
						}else{
							this.$message({
								message: '获取初录规则设置数据失败',
								type: 'warning'
							});
						}
					})
					.catch(err=>{
						console.log(err)
						this.$message({
							message: '获取初录规则设置数据异常',
							type: 'warning'
						});
					})
			},
			getSecData(){
				let that = this
				this.$fetch(FIND_RULE_LOTTERY_BY_CODE,
						{
						"activityCode":this.activityCode,
						'repeatRecord':'1',
						},
					)
					.then(res=>{
						if(res.status == 1){
							let data = res.data
							if(data && this.repeatRecord == 1){
								this.updateData(data)
							}else{
								if(sessionStorage.getItem('activityScenes') == '994001'){

								}else{
									that.diffUserLabel = that.repeatRecordContent.userLabel != '982002'
								}
								that.diffJoin = that.repeatRecordContent.userSingleCount != 0
								that.diffSingleMoney = that.repeatRecordContent.userSingleMoney != 0
								that.diffTotalJoin = that.repeatRecordContent.userTotalCount != 0
								that.diffTotalJoin = that.repeatRecordContent.userTotalCount != 0
								that.diffUserTotalMoney = that.repeatRecordContent.userTotalMoney != 0
								that.diffReceive = that.repeatRecordContent.userReceiveTotal != 0
								that.diffMoneyReceiveTotal = that.repeatRecordContent.moneyReceiveTotal != 0
							}
						}else{
							this.$message({
								message: '获取复录规则活动设置数据失败',
								type: 'warning'
							});
						}
					})
					.catch(err=>{
						console.log(err)
						this.$message({
							message: '获取复录规则活动设置数据异常',
							type: 'warning'
						});
					})
			},
			updateData(data){
				this.userLabel = data.userLabel

				//用户单次参加次数
				if(data.userSingleCount == 0){
					this.userSingleCountType = '0'
				}else if(data.userSingleCount > 0){
					this.userSingleCountType = '1'
					this.userSingleCount = data.userSingleCount
					this.limitCount = data.limitCount
				}
				//用户活动参加次数
				if(data.userTotalCount == 0){
					this.userJoinType = '0'
					this.isUserTotalCount = true
				}else if(data.userTotalCount > 0){
					this.userJoinType = '1'
					this.isUserTotalCount = false
				}
				this.userTotalCount = data.userTotalCount

				//用户单次获取金额
				if(data.userSingleMoney == 0){
					this.userSingleMoneyType = '0'
				}else if(data.userSingleMoney > 0){
					this.userSingleMoneyType = '1'
					this.userSingleMoney = data.userSingleMoney
					this.limitMoney = data.limitMoney
				}
				//用户活动获取金额
				if(data.userTotalMoney == 0){
					this.userTotalMoneyType = '0'
				}else if(data.userTotalMoney > 0){
					this.userTotalMoneyType = '1'
					this.userTotalMoney = Number(data.userTotalMoney).toFixed(2)
				}

				//总领取人数
				if(data.userReceiveTotal == 0){
					this.userReceiveTotalType = '0'
				}else{
					this.userReceiveTotalType = '1'
				}
				this.userReceiveTotal = data.userReceiveTotal

				//总发放金额
				if(data.moneyReceiveTotal == 0){
					this.moneyReceiveTotalType = '0'
				}else{
					this.moneyReceiveTotalType = '1'
				}
				this.moneyReceiveTotal = data.moneyReceiveTotal


				if(this.repeatRecord == 1){
					let num = this.repeatRecordContent.moneyAlarmLimit == data.moneyAlarmLimit
					let email = this.repeatRecordContent.emailAlarm == data.emailAlarm
					if(num && email){
						this.diffLeftAlarm = true
					}else{
						this.diffLeftAlarm = false
					}
				}
				this.moneyAlarmLimit = data.moneyAlarmLimit
				this.emailAlarm = data.emailAlarm

				//分享
				this.shareTitle = data.shareTitle
				this.shareContent = data.shareContent
				this.shareImg = data.shareImg
				this.shareImageUrl = data.shareImg
				this.shareImgMd5 = data.shareImgMd5
			},
			homeImgSuccess(res, file) {
				this.shareImageUrl = res.url;
				// this.shareImageUrl = URL.createObjectURL(file.raw);
				this.shareImg = res.url
				this.shareImgMd5 = res.fileMD5
				this.$refs.shareImg.clearFiles()
			},
			beforeAvatarUpload(file) {
				let name = file.name.split('.')
				const isJpg = name[name.length-1].toLowerCase() === 'jpg'|| name[name.length-1].toLowerCase() === 'png';

				// const isJPG = file.type === 'image/jpeg';
				const isLt2M = file.size / 1024 / 1024 < 1;

				if (!isLt2M) {
					this.$message.error('上传图片大小不能超过 1MB!');
				}
				if (!isJpg) {
					this.$message.error('只能上传jpg或png格式文件');
				}
				const isCh = /^[^\u4e00-\u9fa5]+$/.test(name[name.length-2]);
				if (!isCh) {
					this.$message.error('上传的文件名称不能有中文!');
				}
				return isLt2M && isJpg && isCh;
			},
			alarmAlert() {
				if(this.canAlram){
					this.showAlarmDiv = true;
				}
			},
			closeAlarm(data) {
				if(data){
					this.moneyAlarmLimit = data.money
					this.emailAlarm = data.email
					this.diffLeftAlarm = data.isSame
				}
				this.showAlarmDiv = false;
			},
			goPrize(type) {
				if(type == -1){
					this.$router.push('/settingIndex/newBasics')
					Bus.$emit("changeStep");
				}else{
					if(this.userReceiveTotal == 0){
						this.userTotal = 0
					}
					if(this.moneyReceiveTotal == 0){
						this.money = 0
					}
	
					if(this.shareImageUrl){
						if(this.showTheme || this.showContent){
							this.$message.error('分享标题或分享描述格式错误');
							return;
						}
						if(this.repeatRecord == 0){
							this.isIdentical = 0
						}else{
							if(this.diffUserLabel || this.diffJoin || this.diffReceive || this.diffMoneyReceiveTotal || !this.diffLeftAlarm){
								this.isIdentical = 1
							}else{
								this.isIdentical = 0
							}
						}
						if(this.userSingleCountType == '1'){
							if(this.limitCount == '' || this.userSingleCount == ''){
								this.$message.error('用户单次参与次数数据不能为空');
								return;
							}else{
								if(!this.checkNum(Number(this.limitCount)) || !this.checkNum(Number(this.userSingleCount))){
									this.$message.error('用户单次参与次数数据只能为数字');
									return;
								}
							}
						}
						if(this.userJoinType == '1'){
							if(this.userTotalCount == ''){
								this.$message.error('用户活动参加次数数据不能为空');
								return;
							}else{
								if(!this.checkNum(Number(this.userTotalCount))){
									this.$message.error('用户活动参加次数数据只能为数字');
									return;
								}
							}
						}
						if(this.userSingleMoneyType == '1'){
							if(this.limitMoney == '' || this.userSingleMoney == ''){
								this.$message.error('用户单次获取金额数据不能为空');
								return;
							}else{
								if(!this.checkNum(Number(this.limitMoney)) || !this.checkNum(Number(this.userSingleMoney))){
									this.$message.error('用户单次获取金额数据只能为数字');
									return;
								}
							}
						}
						if(this.userTotalMoneyType == '1'){
							if(this.userTotalMoney == ''){
								this.$message.error('用户活动获取金额数据不能为空');
								return;
							}else{
								if(!this.checkNum(Number(this.userTotalMoney))){
									this.$message.error('用户活动获取金额数据只能为数字');
									return;
								}
							}
						}
						if(this.userReceiveTotalType == '1'){
							if(this.userReceiveTotal == ''){
								this.$message.error('总领取人数数据不能为空');
								return;
							}else{
								if(!this.checkNum(Number(this.userReceiveTotal))){
									this.$message.error('总领取人数数据只能为数字');
									return;
								}
							}
						}
						if(this.moneyReceiveTotalType == '1'){
							if(this.moneyReceiveTotal == ''){
								this.$message.error('总发放金额数据不能为空');
								return;
							}else{
								if(!this.checkNum(Number(this.moneyReceiveTotal))){
									this.$message.error('总发放金额数据只能为数字');
									return;
								}else{
									if(Number(this.moneyReceiveTotal)<100){
										this.$message.error('总发放金额不能小于100');
										return;
									}
								}
							}
						}

						this.$post(SAVE_OR_EDIT_RULE_LOTTERY,
							{
							"activityCode":this.activityCode,
							'userLabel':this.userLabel,
							'userTotalCount':this.userTotalCount,
							'userSingleCount':this.userSingleCount,
							'userSingleMoney':this.userSingleMoney,
							'userTotalMoney':this.userTotalMoney,
							'limitCount':this.limitCount,
							'limitMoney':this.limitMoney,
							'userReceiveTotal':this.userReceiveTotal,
							'moneyReceiveTotal':this.moneyReceiveTotal,
							'moneyAlarm':this.moneyAlarm,
							'moneyAlarmLimit':this.moneyAlarmLimit,
							'emailAlarm':this.emailAlarm,
							'shareTitle':this.shareTitle,
							'shareContent':this.shareContent,
							'shareImg':this.shareImg,
							'shareImgMd5':this.shareImgMd5,
							'activityType':this.receiveType,
							'repeatRecord':this.repeatRecord,
							'isIdentical':this.isIdentical,
							},
						)
						.then(res=>{
							if(res.status == 1){
								this.$message({
									message: '保存成功',
									type: 'success'
								});
	
								if(type == 1){
									this.clickNext = true
									Bus.$emit('changePrize','/settingIndex/newPrize')
									Bus.$emit('changeStep')
									this.$router.push('/settingIndex/newPrize')
								}
							}else{
								this.$message({
									message: '保存失败',
									type: 'warning'
								});
							}
						})
						.catch(err=>{
							console.log(err)
							this.$message({
								message: '保存失败',
								type: 'warning'
							});
						})
		
					}else{
						this.$message({
							message: '必填项不能为空',
							type: 'error'
						});
					}
				}
			}
		}
	}
</script>

<style lang="less">
	.rulesBox {
		width: 65%;
		margin: auto;
		margin-top: 0.1rem;
		input[type="file"]{
			display: none;
		}
		.newRules .el-upload {
			border: 1px dashed #d9d9d9;
			border-radius: 6px;
			cursor: pointer;
			position: relative;
			overflow: hidden;
		}
		.newRules .el-upload:hover {
			border-color: #409EFF;
		}
		.avatar-uploader-icon {
			font-size: 28px;
			color: #8c939d;
			width: 50px;
			height: 50px;
			line-height: 50px;
			text-align: center;
		}
		.avatar {
			width: 100px;
			height: 100px;
			display: block;
		}	
		.ruleText {
			width: 100%;
			color: #3395FF;
			font-size: 0.1rem;
			border-bottom: 1px solid rgba(240, 241, 242, 1);
			margin-bottom: 0.12rem;
		}
		.ruleText1::after{
			content: '';
			display: block;
			width: 0.4rem;
			height: 0.016rem;
			background: rgba(51,149,255,1);
		}
		.ruleText2::after{
			content: '';
			display: block;
			width: 0.6rem;
			height: 0.016rem;
			background: rgba(51,149,255,1);
		}
		
		.topRules {
			width: 77%;
			margin: auto;
		}
		
		.topRules .el-input,
		.topRules .el-select {
			width: 0.68rem;
		}
		
		.topRules .el-input__inner {
			width: 100%;
		}
		
		.operateDiv {
			width: 100%;
			margin: auto;
			margin-bottom: 0.15rem;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			margin-left: 0;
			position: relative;
			.checkTxt{
				color: #FF2E2E;
				position: absolute;
				right: -25%;
			}
		}
		
		.operateText {
			text-align: end;
			width: 19%;
			margin-right: 0.08rem;
		}
		
		.scount {
			margin-left: 0.05rem;
    		margin-right: 0.05rem;
		}
		.scount1{
			margin-right: 0.05rem;
		}
		.item{
			margin-left: 0.05rem;
		}

		
		.alarm {
			color: #3395FF;
			text-decoration: underline;
			margin-left: 0.1rem;
			cursor: pointer;
		}
		
		.textTip {
			padding-top: 0.05rem;
			color: #999;
		}
		
	}
			.btns {
				position: fixed;
				bottom:0.15rem;
				left:45%;
			}
			
			.pageBtn {
				width: 0.8rem;
				height: 0.2rem;
				background: #3395FF;
				border-radius: 8px;
				color: #fff;
				margin-left: 0.2rem;
			}
			
			// .next {
			// 	background: #A9D0FF;
			// }
	
</style>